package bdd;

import beans.*;
import java.sql.*;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author CDI201
 */
public class QueriesDetailCommande {

    Connection cnx;

    public QueriesDetailCommande() throws ClassNotFoundException, SQLException {
        cnx = ConnectBDD.getSingleton();

    }

    public ArrayList<DetailCommande> selectAll() throws SQLException {

        ArrayList<DetailCommande> DetCom = new ArrayList();
        String req = "select * from v_AfficherCommandeDuClient";
        Statement stm = cnx.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

        ResultSet res = stm.executeQuery(req);

        while (res.next()) {


            DetailCommande DCom = new DetailCommande();

            DCom.setLIVISBN(res.getString("LIV_ISBN"));
            DCom.setLIVTITRE(res.getString("LIV_TITRE"));
            DCom.setPrixttc(res.getFloat("Prixttc"));
            DCom.setCLIID(res.getInt("CLI_ID"));
            DCom.setCLINOM(res.getString("CLI_NOM"));
            DCom.setCLIPRENOM(res.getString("CLI_PRENOM"));
            DCom.setCLISEXE(res.getString("CLI_SEXE"));
            DCom.setCMDID(res.getInt("CMD_ID"));
            DCom.setCMDDATE(res.getDate("CMD_DATE"));
            DCom.setADRESSELIVRAISON(res.getString("STA_LABEL"));
            DCom.setQuantite(res.getInt("quantite"));
            DCom.setADRESSEFACTURATION(res.getString("TAD_LABEL"));
            DCom.setADRRUE2(res.getString("ADR_RUE2"));
            DCom.setADRVILLE(res.getString("ADR_VILLE"));
            DCom.setADRCP(res.getString("ADR_CP"));

            //DCom.setLIV_ID(res.getInt("LIV_ID"));
            //  DCom.setLIV_PRIXHT(res.getFloat("LIV_PRIXHT"));
            DetCom.add(DCom);

        }

        return DetCom;

    }

    public void GCombo() {
        try {
            String sql = "select * from v_AfficherCommandeDuClient ";
            Statement stm = cnx.createStatement();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex);
        }
    }
}
